package com.xyhuo.leetcode.y2025;

public class IsPowerOfTwo {
    public boolean isPowerOfTwo(int n) {
        if (n <= 0) {
            return false;
        }
        while (n != 1) {
            int nextN = n >> 1;
            if (nextN * 2 != n) {
                return false;
            }
            n = nextN;
        }
        return true;
    }

    public static void main(String[] args) {
        IsPowerOfTwo i = new IsPowerOfTwo();
        i.isPowerOfTwo(-16);
    }
}
